package com.aaa.controller;

import com.aaa.entity.Orders;
import com.aaa.service.OrdersService;
import com.aaa.util.DefaultMsg;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/orders")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;
    @PostMapping("/listData")
    public PageInfo<Orders> listData(@RequestParam(defaultValue = "") String keyword, Integer currentPage, Integer pageSize){
        PageHelper.startPage(currentPage,pageSize);
        List<Orders> leadingUsers = ordersService.listAll(keyword);
        PageInfo pageInfo=new PageInfo(leadingUsers);
        return pageInfo;
    }
    @RequestMapping("/del")
    public DefaultMsg delete(Integer oid){
        DefaultMsg defaultMsg = ordersService.delete(oid);
        return defaultMsg;
    }
}
